package cn.kgc.javaweb.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: mosin
 * @version: v1.0  2022/10/30
 * 实现  用户信息的  查询  增加  删除 修改 分页
 *
 *  add   select   update
 *
 *  /user?method=add
 *  /user?method=delete
 *  /user?method=update
 *  /user?method=select
 *
 */
@WebServlet("/user")
public class UserServlet extends HttpServlet{

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 获取method的值  进行操作方法的选择
        String method = req.getParameter("method");

        switch (method) {
            case "add":
                add(req, resp);
                break;
            case "delete":
                delete(req, resp);
                break;
            case "update":
                update(req, resp);
                break;
            case "select":
                select(req, resp);
                break;
        }


    }


    protected void add(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("add");
    }


    protected void select(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("select");
    }


    protected void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("update");
    }

    protected void delete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("delete");
    }


}
